package com.java.main;

import java.util.Date;
import java.util.List;
import java.util.Scanner;

import com.java.dao.PassengerDao;
import com.java.dao.RrcDao;
import com.java.entity.Passenger;
import com.java.entity.Rrc;

public class Main {
	static PassengerDao pdao = new PassengerDao();
	static RrcDao rdao = new RrcDao();
	
	
	public static void main(String[] args) {
		int i = 0;
		while(true) {
			System.out.println("选择功能");
			System.out.println("1.insert rrc\t2.select all rrc");
			System.out.println("3.inert passenger\t4.select all passenger");
			Scanner input = new Scanner(System.in);
			int num = input.nextInt();
			
			switch (num) {
			case 1:
				Rrc rrc = new Rrc();
				rrc.setNumber(100+i);
				rrc.setRegistertime(new Date());
				rrc.setRisk(i);
				rdao.insert(rrc);
				System.out.println("添加成功!");
				break;
			case 2:
				System.out.println("信息如下:");
				List<Rrc> list = rdao.queryAll();
				for (int j = 0; j < list.size(); j++) {
					System.out.println(list.get(j).toString());
				}
				break;
			case 3:
				Passenger p = new Passenger();
				p.setBirthdate(new Date());
				p.setEducationdegreeid(i);
				p.setGenderid(i);
				p.setLicenceissuingauthorty("test");
				p.setName("test");
				p.setNationid(i);
				p.setPapersid(i);
				p.setPapersnumber("number");
				p.setPapersvaildity("str");
				p.setPassengerlevelid(i);
				p.setUnitsoraddress("address");
				pdao.insert(p);
				System.out.println("添加成功");
				break;
			case 4:
				List<Passenger> pList = pdao.queryAll();
				for (int j = 0; j < pList.size(); j++) {
					System.out.println(pList.get(j).toString());
				}
				break;
			default:
				System.out.println("输入错误");
				break;
			}
		}
		
		
	}
}
